
package uk.org.cardboardbox.nfcpointstracker.dialog;

import uk.org.cardboardbox.nfcpointstracker.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;

public class AddPointsDialog extends AlertDialog {

    public interface Listener {
        public void onPointsSelected(int points);

        public void onCancelled();
    }

    private final Listener listener;

    public AddPointsDialog(Context context, Listener listener) {
        super(context);
        this.listener = listener;
        init(context);
    }

    private final void init(Context context) {
        setTitle("Add points");
        LayoutInflater li = (LayoutInflater)context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View content = li.inflate(R.layout.addpoints, null);
        setView(content);
        setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                listener.onPointsSelected(5);
            }
        });
        setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel),
                new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        listener.onCancelled();
                    }
                });

    }
}
